<?php

class Customers extends CActiveRecord
{
	/**
	 * The followings are the available columns in table 'customers':
	 * @var integer $customers_id
	 * @var string $customers_company_name
	 * @var string $customers_firstname
	 * @var string $customers_lastname
	 * @var string $customers_street
	 * @var string $customers_house_nr
	 * @var string $customers_zip
	 * @var string $customers_city
	 * @var string $customers_country_code
	 * @var string $customers_area_code
	 * @var string $customers_telephone
	 * @var string $customers_fax
	 * @var string $customers_mobile
	 * @var string $customers_email
	 * @var string $cutomers_created_at
	 * @var string $cutomers_changed_at
	 */

	/**
	 * Returns the static model of the specified AR class.
	 * @return CActiveRecord the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'customers';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('customers_firstname, customers_lastname, customers_street, customers_house_nr, customers_zip, customers_country_code, customers_telephone, cutomer_created_at, cutomer_changed_at', 'required'),
			array('customers_company_name', 'length', 'max'=>150),
			array('customers_firstname, customers_lastname', 'length', 'max'=>100),
			array('customers_street, customers_city', 'length', 'max'=>255),
			array('customers_house_nr, customers_telephone, customers_fax, customers_mobile, customers_email', 'length', 'max'=>50),
			array('customers_zip, customers_country_code, customers_area_code', 'length', 'max'=>5),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'customer_contact_persons' => array(self::HAS_MANY, 'CustomerContactPersons', 'customer_contact_persons_customers_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'customers_id' => Yii::t('crm', 'ID'),
			'customers_company_name' => Yii::t('crm', 'Firmenname'),
			'customers_firstname' => Yii::t('crm', 'Vorname'),
			'customers_lastname' => Yii::t('crm', 'Nachname'),
			'customers_street' => Yii::t('crm', 'Straße'),
			'customers_house_nr' => Yii::t('crm', 'Hausnummer'),
			'customers_zip' => Yii::t('crm', 'PLZ'),
			'customers_country_code' => Yii::t('crm', 'Land'),
			'customers_area_code' => Yii::t('crm', 'Vorwahl'),
			'customers_telephone' => Yii::t('crm', 'Rufnummer'),
			'customers_fax' => Yii::t('crm', 'Faxnummer'),
			'customers_mobile' => Yii::t('crm', 'Handynummer'),
			'customers_email' => Yii::t('crm', 'E-Mail-Adresse'),
		);
	}
}